SUFFIXES=.1 .dvi .prt .ps .dmp .dat .scr .sky .me .lst .X

ROFF=groff
PIC=-p
#FONT=-fH
#DEV=-Tdvi -P-d  # The -P-d suppresses 'special' draw commands - only
                 # horiz & vertical lines can be drawn
DEV=-Tps

PRE=-man
TAB=-t
# OPT comes from the command line

all: man

.dat.dmp:
		../src/tools/smcreate -d $* $? >$*.dmp

.dmp.scr:
		sed -f dump2man.sed $*.dmp >$*.scr

.1.ps:
		soelim $*.1 | $(ROFF) -man $(FONT) $(PIC) $(TAB) $(OPT) $(DEV) >$*.ps

.1.X:
		soelim $*.1 | $(ROFF) -man -TXps $(FONT) $(PIC) $(TAB) $(OPT)

.1.lst:
		grep -v $* listcomm |sed -e 's/.*/.BR & (1),/'|sed -e '$$s/\(.*\),/\1/' >$*.lst

.me.ps:
		soelim $*.me | $(ROFF) -me $(FONT) $(PIC) $(TAB) $(OPT) $(DEV) >$*.ps

.me.X:
		soelim $*.me | $(ROFF) -me -TXps $(FONT) $(PIC) $(TAB) $(OPT)

man_MANS = \
scrmgr.1 \
sm2awk.1 \
sm2c.1 \
smclean.1 \
smcreate.1 \
smdata.1 \
smdisp.1 \
smedit.1 \
smfind.1 \
smgrep.1 \
smproj.1 \
smquick.1 \
smsort.1 \
smupdate.1 \
pcurse.1

pkgdata = 
EXTRA_DIST = $(man_MANS) extramac listcomm

POSTSCRIPT_MAN= \
scrmgr.ps \
sm2awk.ps \
sm2c.ps \
smclean.ps \
smcreate.ps \
smdata.ps \
smdisp.ps \
smedit.ps \
smfind.ps \
smgrep.ps \
smproj.ps \
smquick.ps \
smsort.ps \
smupdate.ps \
xctool.ps

postscript_man: $(POSTSCRIPT_MAN)

$(POSTSCRIPT_MAN): listcomm extramac dump2man.sed

flrecord.dmp: ../src/tools/smcreate.dat
	../src/tools/smcreate -d FILE_RECORD $? >$@
fdrecord.dmp: ../src/tools/smcreate.dat
	../src/tools/smcreate -d FIELD_RECORD $? >$@
screcord.dmp: ../src/tools/smcreate.dat
	../src/tools/smcreate -d SCREEN_RECORD $? >$@
kyrecord.dmp: ../src/tools/smcreate.dat
	../src/tools/smcreate -d KEY_RECORD $? >$@
main.sky:  ../src/tools/smcreate.dat
	../src/tools/smcreate -k main_skey $? >$@
file.sky:  ../src/tools/smcreate.dat
	../src/tools/smcreate -k file_skey $? >$@
softkey.sky:  ../src/tools/smcreate.dat
	../src/tools/smcreate -k softkey_skey $? >$@
scrfield.sky:  ../src/tools/smcreate.dat
	../src/tools/smcreate -k screen_field_skey $? >$@
editfld.sky:  ../src/tools/smcreate.dat
	../src/tools/smcreate -k edit_field_skey $? >$@
screen.sky:  ../src/tools/smcreate.dat
	../src/tools/smcreate -k screen_skey $? >$@
scr_name.sky:  ../src/tools/smcreate.dat
	../src/tools/smcreate -k scr_name_skey $? >$@

smcreate.ps: smcreate.1 flrecord.scr fdrecord.scr screcord.scr kyrecord.scr extramac main.sky file.sky scrfield.sky editfld.sky screen.sky scr_name.sky softkey.sky smcreate.lst

sm_where.dmp: ../smbuilt.dat
	../src/tools/smcreate -d sm_where_scr $? >$@
strfiles.dmp: ../smdata.dat
	../src/tools/smcreate -d store_files_scr $? >$@
smdamain.sky:  ../smdata.dat
	../src/tools/smcreate -k smdata_main_skey $? >$@
strfiles.sky:  ../smdata.dat
	../src/tools/smcreate -k store_files_skey $? >$@
sm_data.sky:  ../smbuilt.dat
	../src/tools/smcreate -k sm_data_skey $? >$@
sm_other.sky:  ../smbuilt.dat
	../src/tools/smcreate -k sm_second_data_skey $? >$@
sm_sort.sky:  ../smbuilt.dat
	../src/tools/smcreate -k sm_sort_skey $? >$@
sm_where.sky:  ../smbuilt.dat
	../src/tools/smcreate -k sm_where_skey $? >$@

smdata.ps: smdata.1 sm_where.scr strfiles.scr smdamain.sky strfiles.sky sm_data.sky sm_other.sky sm_sort.sky sm_where.sky smdata.lst

man manuals: pcurse.lst
	-mkdir -p man1
	for i in $(MANUALS); \
	do \
		soelim $$i | \
		sed -e 's/^box "/.bx "/' >man1/$$i; \
	done

sm2awk.ps   : sm2awk.lst
sm2c.ps     : sm2c.lst
smcalc.ps   : smcalc.lst
smclean.ps  : smclean.lst
smedit.ps   : smedit.lst
smfind.ps   : smfind.lst
smdisp.ps   : smdisp.lst
smgrep.ps   : smgrep.lst
smproj.ps   : smproj.lst
smquick.ps  : smquick.lst
smsort.ps   : smsort.lst
smtree.ps   : smtree.lst
smupdate.ps : smupdate.lst
xctool.ps   : xctool.lst
